function FilePreviewer() {
}
FilePreviewer.prototype = {
    preViewFile:function (dataId,viewId,data) {
        var frameUrl = 'http://base1.zhihuishu.com/able-commons/resources/demos/ablefilebrowser/swfReader.jsp?id='+viewId+'&z_language='+z_locale;
        console.log(frameUrl);
        $("#layerFilePreview-iframe").attr("src",frameUrl);
        $("#layerFilePreview").data("data",data);

        var offTop = "auto";
        if($(window).height() <= 768){
            offTop = "0px";
        }
        layer.open({
            type: 1,
            shift: 5,
            shade: [0.5, '#393D49'],
            offset: [offTop],
            title: zLocale.common_file_preview,
            area: ['860px', '660px'],
            fix: false,
            //不固定
            move: false,
            // maxmin: true,
            //最大化最小化
            zIndex: 9900,
            content:$("#layerFilePreview"),
            // content: 'http://base1.zhihuishu.com/able-commons/resources/demos/ablefilebrowser/swfReader.jsp?id='+data.interfaceDataId,
            end: function() { //关闭弹窗

            }
        });


    },
    downloadFile:function () {
        var dt = $("#layerFilePreview").data("data");
        if(dt.url){
            window.open(dt.url,"_self");
        }
    },
    downloadPic:function (imgURL) {
        // window.open(imgURL,"_blank");

        //chrome only
        if(_navig.chrome){
            var $a = $("<a></a>").attr("href", imgURL).attr("download", "img.png");
            // var $a = $("<a></a>").attr("href", "/asdasd").attr("download", "img.png");
            $a[0].click();
            // $a.click();
            $a.remove();
        }else {

            //其它只能通过返回头触发浏览器下载
            // window.open(basePath+"/course/thirdStep/file/download?url="+imgURL);
            window.open(basePath+"/course/thirdStep/file/download?url="+imgURL,_filePreviewer.getExplorerOpenType());
        }

    },
    getExplorerOpenType:function () {
        var defaultOpenType = "_self";
        if(_navig.firefox ){
            defaultOpenType="_blank";
        }
        return defaultOpenType;
    }
}

var _filePreviewer = new FilePreviewer();